home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / andere sprachen / perl5 / man / catp / perlform.0 < prev    next >
Text File  |  1996-03-02  |  30KB  |  463 lines

  1.  
  2.  
  3.  
  4. PERLFORM(1)    User Contributed Perl Documentation    PERLFORM(1)
  5.  
  6.  
  7. NNNNAAAAMMMMEEEE
  8.        perlform - Perl formats
  9.  
  10. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  11.        Perl has a mechanism to help you generate simple reports
  12.        and charts.  To facilitate this, Perl helps you code up
  13.        your output page close to how it will look when it's
  14.        printed.  It can keep track of things like how many lines
  15.        on a page, what page you're on, when to print page
  16.        headers, etc.  Keywords are borrowed from FORTRAN:
  17.        _f_o_r_m_a_t_(_) to declare and _w_r_i_t_e_(_) to execute; see their
  18.        entries in the _p_e_r_l_f_u_n_c manpage.  Fortunately, the layout
  19.        is much more legible, more like BASIC's PRINT USING
  20.        statement.  Think of it as a poor man's _n_r_o_f_f(1).
  21.  
  22.        Formats, like packages and subroutines, are declared
  23.        rather than executed, so they may occur at any point in
  24.        your program.  (Usually it's best to keep them all
  25.        together though.) They have their own namespace apart from
  26.        all the other "types" in Perl.  This means that if you
  27.        have a function named "Foo", it is not the same thing as
  28.        having a format named "Foo".  However, the default name
  29.        for the format associated with a given filehandle is the
  30.        same as the name of the filehandle.  Thus, the default
  31.        format for STDOUT is name "STDOUT", and the default format
  32.        for filehandle TEMP is name "TEMP".  They just look the
  33.        same.  They aren't.
  34.  
  35.        Output record formats are declared as follows:
  36.  
  37.            ffffoooorrrrmmmmaaaatttt NNNNAAAAMMMMEEEE ====
  38.            FFFFOOOORRRRMMMMLLLLIIIISSSSTTTT
  39.            ....
  40.  
  41.        If name is omitted, format "STDOUT" is defined.  FORMLIST
  42.        consists of a sequence of lines, each of which may be of
  43.        one of three types:
  44.  
  45.        1.  A comment, indicated by putting a '#' in the first
  46.            column.
  47.  
  48.        2.  A "picture" line giving the format for one output
  49.            line.
  50.  
  51.        3.  An argument line supplying values to plug into the
  52.            previous picture line.
  53.  
  54.        Picture lines are printed exactly as they look, except for
  55.        certain fields that substitute values into the line.  Each
  56.        field in a picture line starts with either "@" (at) or "^"
  57.        (caret).  These lines do not undergo any kind of variable
  58.        interpolation.  The at field (not to be confused with the
  59.        array marker @) is the normal kind of field; the other
  60.        kind, caret fields, are used to do rudimentary multi-line
  61.  
  62.  
  63.  
  64. 30/Jan/96                perl 5.002 with                        1
  65.  
  66.  
  67.  
  68.  
  69.  
  70. PERLFORM(1)    User Contributed Perl Documentation    PERLFORM(1)
  71.  
  72.  
  73.        text block filling.  The length of the field is supplied
  74.        by padding out the field with multiple "<", ">", or "|"
  75.        characters to specify, respectively, left justification,
  76.        right justification, or centering.  If the variable would
  77.        exceed the width specified, it is truncated.
  78.  
  79.        As an alternate form of right justification, you may also
  80.        use "#" characters (with an optional ".") to specify a
  81.        numeric field.  This way you can line up the decimal
  82.        points.  If any value supplied for these fields contains a
  83.        newline, only the text up to the newline is printed.
  84.        Finally, the special field "@*" can be used for printing
  85.        multi-line, non-truncated values; it should appear by
  86.        itself on a line.
  87.  
  88.        The values are specified on the following line in the same
  89.        order as the picture fields.  The expressions providing
  90.        the values should be separated by commas.  The expressions
  91.        are all evaluated in a list context before the line is
  92.        processed, so a single list expression could produce
  93.        multiple list elements.  The expressions may be spread out
  94.        to more than one line if enclosed in braces.  If so, the
  95.        opening brace must be the first token on the first line.
  96.  
  97.        Picture fields that begin with ^ rather than @ are treated
  98.        specially.  With a # field, the field is blanked out if
  99.        the value is undefined.  For other field types, the caret
  100.        enables a kind of fill mode.  Instead of an arbitrary
  101.        expression, the value supplied must be a scalar variable
  102.        name that contains a text string.  Perl puts as much text
  103.        as it can into the field, and then chops off the front of
  104.        the string so that the next time the variable is
  105.        referenced, more of the text can be printed.  (Yes, this
  106.        means that the variable itself is altered during execution
  107.        of the _w_r_i_t_e_(_) call, and is not returned.)  Normally you
  108.        would use a sequence of fields in a vertical stack to
  109.        print out a block of text.  You might wish to end the
  110.        final field with the text "...", which will appear in the
  111.        output if the text was too long to appear in its entirety.
  112.        You can change which characters are legal to break on by
  113.        changing the variable $$$$:::: (that's
  114.        $$$$FFFFOOOORRRRMMMMAAAATTTT____LLLLIIIINNNNEEEE____BBBBRRRREEEEAAAAKKKK____CCCCHHHHAAAARRRRAAAACCCCTTTTEEEERRRRSSSS if you're using the English
  115.        module) to a list of the desired characters.
  116.  
  117.        Using caret fields can produce variable length records.
  118.        If the text to be formatted is short, you can suppress
  119.        blank lines by putting a "~" (tilde) character anywhere in
  120.        the line.  The tilde will be translated to a space upon
  121.        output.  If you put a second tilde contiguous to the
  122.        first, the line will be repeated until all the fields on
  123.        the line are exhausted.  (If you use a field of the at
  124.        variety, the expression you supply had better not give the
  125.        same value every time forever!)
  126.  
  127.  
  128.  
  129.  
  130. 30/Jan/96                perl 5.002 with                        2
  131.  
  132.  
  133.  
  134.  
  135.  
  136. PERLFORM(1)    User Contributed Perl Documentation    PERLFORM(1)
  137.  
  138.  
  139.        Top-of-form processing is by default handled by a format
  140.        with the same name as the current filehandle with "_TOP"
  141.        concatenated to it.  It's triggered at the top of each
  142.        page.  See <perlfunc/_w_r_i_t_e_(_)>.
  143.  
  144.        Examples:
  145.  
  146.         #### aaaa rrrreeeeppppoooorrrrtttt oooonnnn tttthhhheeee ////eeeettttcccc////ppppaaaasssssssswwwwdddd ffffiiiilllleeee
  147.         ffffoooorrrrmmmmaaaatttt SSSSTTTTDDDDOOOOUUUUTTTT____TTTTOOOOPPPP ====
  148.                                 PPPPaaaasssssssswwwwdddd FFFFiiiilllleeee
  149.         NNNNaaaammmmeeee                LLLLooooggggiiiinnnn    OOOOffffffffiiiicccceeee   UUUUiiiidddd   GGGGiiiidddd HHHHoooommmmeeee
  150.         ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  151.         ....
  152.         ffffoooorrrrmmmmaaaatttt SSSSTTTTDDDDOOOOUUUUTTTT ====
  153.         @@@@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @@@@|||||||||||||||||||||||||||| @@@@<<<<<<<<<<<<<<<<<<<<<<<<@@@@>>>>>>>>>>>>>>>> @@@@>>>>>>>>>>>>>>>> @@@@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  154.         $$$$nnnnaaaammmmeeee,,,,              $$$$llllooooggggiiiinnnn,,,,  $$$$ooooffffffffiiiicccceeee,,,,$$$$uuuuiiiidddd,,,,$$$$ggggiiiidddd,,,, $$$$hhhhoooommmmeeee
  155.         ....
  156.  
  157.         #### aaaa rrrreeeeppppoooorrrrtttt ffffrrrroooommmm aaaa bbbbuuuugggg rrrreeeeppppoooorrrrtttt ffffoooorrrrmmmm
  158.         ffffoooorrrrmmmmaaaatttt SSSSTTTTDDDDOOOOUUUUTTTT____TTTTOOOOPPPP ====
  159.                                 BBBBuuuugggg RRRReeeeppppoooorrrrttttssss
  160.         @@@@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<     @@@@||||||||||||         @@@@>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  161.         $$$$ssssyyyysssstttteeeemmmm,,,,                      $$$$%%%%,,,,         $$$$ddddaaaatttteeee
  162.         ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  163.         ....
  164.         ffffoooorrrrmmmmaaaatttt SSSSTTTTDDDDOOOOUUUUTTTT ====
  165.         SSSSuuuubbbbjjjjeeeecccctttt:::: @@@@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  166.                  $$$$ssssuuuubbbbjjjjeeeecccctttt
  167.         IIIInnnnddddeeeexxxx:::: @@@@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ^^^^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  168.                $$$$iiiinnnnddddeeeexxxx,,,,                       $$$$ddddeeeessssccccrrrriiiippppttttiiiioooonnnn
  169.         PPPPrrrriiiioooorrrriiiittttyyyy:::: @@@@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< DDDDaaaatttteeee:::: @@@@<<<<<<<<<<<<<<<<<<<<<<<<<<<< ^^^^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  170.                   $$$$pppprrrriiiioooorrrriiiittttyyyy,,,,        $$$$ddddaaaatttteeee,,,,   $$$$ddddeeeessssccccrrrriiiippppttttiiiioooonnnn
  171.         FFFFrrrroooommmm:::: @@@@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ^^^^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  172.               $$$$ffffrrrroooommmm,,,,                         $$$$ddddeeeessssccccrrrriiiippppttttiiiioooonnnn
  173.         AAAAssssssssiiiiggggnnnneeeedddd ttttoooo:::: @@@@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ^^^^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  174.                      $$$$pppprrrrooooggggrrrraaaammmmmmmmeeeerrrr,,,,            $$$$ddddeeeessssccccrrrriiiippppttttiiiioooonnnn
  175.         ~~~~                                    ^^^^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  176.                                              $$$$ddddeeeessssccccrrrriiiippppttttiiiioooonnnn
  177.         ~~~~                                    ^^^^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  178.                                              $$$$ddddeeeessssccccrrrriiiippppttttiiiioooonnnn
  179.         ~~~~                                    ^^^^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  180.                                              $$$$ddddeeeessssccccrrrriiiippppttttiiiioooonnnn
  181.         ~~~~                                    ^^^^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  182.                                              $$$$ddddeeeessssccccrrrriiiippppttttiiiioooonnnn
  183.         ~~~~                                    ^^^^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<............
  184.                                              $$$$ddddeeeessssccccrrrriiiippppttttiiiioooonnnn
  185.         ....
  186.  
  187.        It is possible to intermix _p_r_i_n_t_(_)s with _w_r_i_t_e_(_)s on the
  188.        same output channel, but you'll have to handle $-
  189.        ($FORMAT_LINES_LEFT) yourself.
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196. 30/Jan/96                perl 5.002 with                        3
  197.  
  198.  
  199.  
  200.  
  201.  
  202. PERLFORM(1)    User Contributed Perl Documentation    PERLFORM(1)
  203.  
  204.  
  205.        FFFFoooorrrrmmmmaaaatttt VVVVaaaarrrriiiiaaaabbbblllleeeessss
  206.  
  207.        The current format name is stored in the variable $$$$~~~~
  208.        ($FORMAT_NAME), and the current top of form format name is
  209.        in $$$$^^^^ ($FORMAT_TOP_NAME).  The current output page number
  210.        is stored in $$$$%%%% ($FORMAT_PAGE_NUMBER), and the number of
  211.        lines on the page is in $$$$==== ($FORMAT_LINES_PER_PAGE).
  212.        Whether to autoflush output on this handle is stored in $$$$||||
  213.        ($OUTPUT_AUTOFLUSH).  The string output before each top of
  214.        page (except the first) is stored in $$$$^^^^LLLL
  215.        ($FORMAT_FORMFEED).  These variables are set on a per-
  216.        filehandle basis, so you'll need to _s_e_l_e_c_t_(_) into a
  217.        different one to affect them:
  218.  
  219.            sssseeeelllleeeecccctttt((((((((sssseeeelllleeeecccctttt((((OOOOUUUUTTTTFFFF)))),,,,
  220.                    $$$$~~~~ ==== """"MMMMyyyy____OOOOtttthhhheeeerrrr____FFFFoooorrrrmmmmaaaatttt"""",,,,
  221.                    $$$$^^^^ ==== """"MMMMyyyy____TTTToooopppp____FFFFoooorrrrmmmmaaaatttt""""
  222.                   ))))[[[[0000]]]]))));;;;
  223.  
  224.        Pretty ugly, eh?  It's a common idiom though, so don't be
  225.        too surprised when you see it.  You can at least use a
  226.        temporary variable to hold the previous filehandle: (this
  227.        is a much better approach in general, because not only
  228.        does legibility improve, you now have intermediary stage
  229.        in the expression to single-step the debugger through):
  230.  
  231.            $$$$ooooffffhhhh ==== sssseeeelllleeeecccctttt((((OOOOUUUUTTTTFFFF))));;;;
  232.            $$$$~~~~ ==== """"MMMMyyyy____OOOOtttthhhheeeerrrr____FFFFoooorrrrmmmmaaaatttt"""";;;;
  233.            $$$$^^^^ ==== """"MMMMyyyy____TTTToooopppp____FFFFoooorrrrmmmmaaaatttt"""";;;;
  234.            sssseeeelllleeeecccctttt(((($$$$ooooffffhhhh))));;;;
  235.  
  236.        If you use the English module, you can even read the
  237.        variable names:
  238.  
  239.            uuuusssseeee EEEEnnnngggglllliiiisssshhhh;;;;
  240.            $$$$ooooffffhhhh ==== sssseeeelllleeeecccctttt((((OOOOUUUUTTTTFFFF))));;;;
  241.            $$$$FFFFOOOORRRRMMMMAAAATTTT____NNNNAAAAMMMMEEEE     ==== """"MMMMyyyy____OOOOtttthhhheeeerrrr____FFFFoooorrrrmmmmaaaatttt"""";;;;
  242.            $$$$FFFFOOOORRRRMMMMAAAATTTT____TTTTOOOOPPPP____NNNNAAAAMMMMEEEE ==== """"MMMMyyyy____TTTToooopppp____FFFFoooorrrrmmmmaaaatttt"""";;;;
  243.            sssseeeelllleeeecccctttt(((($$$$ooooffffhhhh))));;;;
  244.  
  245.        But you still have those funny _s_e_l_e_c_t_(_)s.  So just use the
  246.        FileHandle module.  Now, you can access these special
  247.        variables using lower-case method names instead:
  248.  
  249.            uuuusssseeee FFFFiiiilllleeeeHHHHaaaannnnddddlllleeee;;;;
  250.            ffffoooorrrrmmmmaaaatttt____nnnnaaaammmmeeee     OOOOUUUUTTTTFFFF """"MMMMyyyy____OOOOtttthhhheeeerrrr____FFFFoooorrrrmmmmaaaatttt"""";;;;
  251.            ffffoooorrrrmmmmaaaatttt____ttttoooopppp____nnnnaaaammmmeeee OOOOUUUUTTTTFFFF """"MMMMyyyy____TTTToooopppp____FFFFoooorrrrmmmmaaaatttt"""";;;;
  252.  
  253.        Much better!
  254.  
  255. NNNNOOOOTTTTEEEESSSS
  256.        Since the values line may contain arbitrary expressions
  257.        (for at fields, not caret fields), you can farm out more
  258.        sophisticated processing to other functions, like
  259.  
  260.  
  261.  
  262. 30/Jan/96                perl 5.002 with                        4
  263.  
  264.  
  265.  
  266.  
  267.  
  268. PERLFORM(1)    User Contributed Perl Documentation    PERLFORM(1)
  269.  
  270.  
  271.        _s_p_r_i_n_t_f_(_) or one of your own.  For example:
  272.  
  273.            ffffoooorrrrmmmmaaaatttt IIIIddddeeeennnntttt ====
  274.                @@@@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  275.                &&&&ccccoooommmmmmmmiiiiffffyyyy(((($$$$nnnn))))
  276.            ....
  277.  
  278.        To get a real at or caret into the field, do this:
  279.  
  280.            ffffoooorrrrmmmmaaaatttt IIIIddddeeeennnntttt ====
  281.            IIII hhhhaaaavvvveeee aaaannnn @@@@ hhhheeeerrrreeee....
  282.                    """"@@@@""""
  283.            ....
  284.  
  285.        To center a whole line of text, do something like this:
  286.  
  287.            ffffoooorrrrmmmmaaaatttt IIIIddddeeeennnntttt ====
  288.            @@@@||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  289.                    """"SSSSoooommmmeeee tttteeeexxxxtttt lllliiiinnnneeee""""
  290.            ....
  291.  
  292.        There is no builtin way to say "float this to the right
  293.        hand side of the page, however wide it is."  You have to
  294.        specify where it goes.  The truly desperate can generate
  295.        their own format on the fly, based on the current number
  296.        of columns, and then _e_v_a_l_(_) it:
  297.  
  298.            $$$$ffffoooorrrrmmmmaaaatttt  ==== """"ffffoooorrrrmmmmaaaatttt SSSSTTTTDDDDOOOOUUUUTTTT ==== \\\\nnnn"""";;;;
  299.                     .... ''''^^^^'''' .... ''''<<<<'''' xxxx $$$$ccccoooollllssss .... """"\\\\nnnn"""";;;;
  300.                     .... ''''$$$$eeeennnnttttrrrryyyy'''' .... """"\\\\nnnn"""";;;;
  301.                     .... """"\\\\tttt^^^^"""" .... """"<<<<"""" xxxx (((($$$$ccccoooollllssss----8888)))) .... """"~~~~~~~~\\\\nnnn"""";;;;
  302.                     .... ''''$$$$eeeennnnttttrrrryyyy'''' .... """"\\\\nnnn"""";;;;
  303.                     .... """"....\\\\nnnn"""";;;;
  304.            pppprrrriiiinnnntttt $$$$ffffoooorrrrmmmmaaaatttt iiiiffff $$$$DDDDeeeebbbbuuuuggggggggiiiinnnngggg;;;;
  305.            eeeevvvvaaaallll $$$$ffffoooorrrrmmmmaaaatttt;;;;
  306.            ddddiiiieeee $$$$@@@@ iiiiffff $$$$@@@@;;;;
  307.  
  308.        Which would generate a format looking something like this:
  309.  
  310.         ffffoooorrrrmmmmaaaatttt SSSSTTTTDDDDOOOOUUUUTTTT ====
  311.         ^^^^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  312.         $$$$eeeennnnttttrrrryyyy
  313.                 ^^^^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<~~~~~~~~
  314.         $$$$eeeennnnttttrrrryyyy
  315.         ....
  316.  
  317.        Here's a little program that's somewhat like _f_m_t(1):
  318.  
  319.         ffffoooorrrrmmmmaaaatttt ====
  320.         ^^^^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~~~~~~~~
  321.         $$$$____
  322.  
  323.         ....
  324.  
  325.  
  326.  
  327.  
  328. 30/Jan/96                perl 5.002 with                        5
  329.  
  330.  
  331.  
  332.  
  333.  
  334. PERLFORM(1)    User Contributed Perl Documentation    PERLFORM(1)
  335.  
  336.  
  337.         $$$$//// ==== '''''''';;;;
  338.         wwwwhhhhiiiilllleeee ((((<<<<>>>>)))) {{{{
  339.             ssss////\\\\ssss****\\\\nnnn\\\\ssss****//// ////gggg;;;;
  340.             wwwwrrrriiiitttteeee;;;;
  341.         }}}}
  342.  
  343.  
  344.        FFFFooooooootttteeeerrrrssss
  345.  
  346.        While $$$$FFFFOOOORRRRMMMMAAAATTTT____TTTTOOOOPPPP____NNNNAAAAMMMMEEEE contains the name of the current
  347.        header format, there is no corresponding mechanism to
  348.        automatically do the same thing for a footer.  Not knowing
  349.        how big a format is going to be until you evaluate it is
  350.        one of the major problems.  It's on the TODO list.
  351.  
  352.        Here's one strategy:  If you have a fixed-size footer, you
  353.        can get footers by checking $$$$FFFFOOOORRRRMMMMAAAATTTT____LLLLIIIINNNNEEEESSSS____LLLLEEEEFFFFTTTT before each
  354.        _w_r_i_t_e_(_) and print the footer yourself if necessary.
  355.  
  356.        Here's another strategy; open a pipe to yourself, using
  357.        ooooppppeeeennnn((((MMMMEEEESSSSEEEELLLLFFFF,,,, """"||||----"""")))) (see the ooooppppeeeennnn(((()))) entry in the _p_e_r_l_f_u_n_c
  358.        manpage) and always _w_r_i_t_e_(_) to MESELF instead of STDOUT.
  359.        Have your child process postprocesses its STDIN to
  360.        rearrange headers and footers however you like.  Not very
  361.        convenient, but doable.
  362.  
  363.        AAAAcccccccceeeessssssssiiiinnnngggg FFFFoooorrrrmmmmaaaattttttttiiiinnnngggg IIIInnnntttteeeerrrrnnnnaaaallllssss
  364.  
  365.        For low-level access to the formatting mechanism.  you may
  366.        use _f_o_r_m_l_i_n_e_(_) and access $$$$^^^^AAAA (the $$$$AAAACCCCCCCCUUUUMMMMUUUULLLLAAAATTTTOOOORRRR variable)
  367.        directly.
  368.  
  369.        For example:
  370.  
  371.            $$$$ssssttttrrrr ==== ffffoooorrrrmmmmlllliiiinnnneeee <<<<<<<<''''EEEENNNNDDDD'''',,,, 1111,,,,2222,,,,3333;;;;
  372.            @@@@<<<<<<<<<<<<  @@@@||||||||||||  @@@@>>>>>>>>>>>>
  373.            EEEENNNNDDDD
  374.  
  375.            pppprrrriiiinnnntttt """"WWWWoooowwww,,,, IIII jjjjuuuusssstttt ssssttttoooorrrreeeedddd ````$$$$^^^^AAAA'''' iiiinnnn tttthhhheeee aaaaccccccccuuuummmmuuuullllaaaattttoooorrrr!!!!\\\\nnnn"""";;;;
  376.  
  377.        Or to make an _s_w_r_i_t_e_(_) subroutine which is to _w_r_i_t_e_(_) what
  378.        _s_p_r_i_n_t_f_(_) is to _p_r_i_n_t_f_(_), do this:
  379.  
  380.            uuuusssseeee CCCCaaaarrrrpppp;;;;
  381.            ssssuuuubbbb sssswwwwrrrriiiitttteeee {{{{
  382.                ccccrrrrooooaaaakkkk """"uuuussssaaaaggggeeee:::: sssswwwwrrrriiiitttteeee PPPPIIIICCCCTTTTUUUURRRREEEE AAAARRRRGGGGSSSS"""" uuuunnnnlllleeeessssssss @@@@____;;;;
  383.                mmmmyyyy $$$$ffffoooorrrrmmmmaaaatttt ==== sssshhhhiiiifffftttt;;;;
  384.                $$$$^^^^AAAA ==== """""""";;;;
  385.                ffffoooorrrrmmmmlllliiiinnnneeee(((($$$$ffffoooorrrrmmmmaaaatttt,,,,@@@@____))));;;;
  386.                rrrreeeettttuuuurrrrnnnn $$$$^^^^AAAA;;;;
  387.            }}}}
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394. 30/Jan/96                perl 5.002 with                        6
  395.  
  396.  
  397.  
  398.  
  399.  
  400. PERLFORM(1)    User Contributed Perl Documentation    PERLFORM(1)
  401.  
  402.  
  403.            $$$$ssssttttrrrriiiinnnngggg ==== sssswwwwrrrriiiitttteeee((((<<<<<<<<''''EEEENNNNDDDD'''',,,, 1111,,,, 2222,,,, 3333))));;;;
  404.         CCCChhhheeeecccckkkk mmmmeeee oooouuuutttt
  405.         @@@@<<<<<<<<<<<<  @@@@||||||||||||  @@@@>>>>>>>>>>>>
  406.         EEEENNNNDDDD
  407.            pppprrrriiiinnnntttt $$$$ssssttttrrrriiiinnnngggg;;;;
  408.  
  409.  
  410. WWWWAAAARRRRNNNNIIIINNNNGGGG
  411.        Lexical variables (declared with "my") are not visible
  412.        within a format unless the format is declared within the
  413.        scope of the lexical variable.  (They weren't visible at
  414.        all before version 5.001.)  Furthermore, lexical aliases
  415.        will not be compiled correctly: see the mmmmyyyy entry in the
  416.        _p_e_r_l_f_u_n_c manpage for other issues.
  417.  
  418.  
  419.  
  420.  
  421.  
  422.  
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460. 30/Jan/96                perl 5.002 with                        7
  461.  
  462.  
  463.